package com.zwf.domain.strategy.model.entity;

import com.zwf.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;


/**
 * @Author zwf
 * @description
 * @date 2024/7/3 14:08
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {

    /** 抽奖策略id */
    private Long strategyId;
    /** 抽奖策略描述 */
    private String strategyDesc;
    /** 规则模型 */
    private String ruleModels;

    //获取所有规则模型
    public String[] ruleModels(){
        if(StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(Constants.SPLIT);
    }

    //检查是否有权重规则模型
    public boolean getRuleWeight() {
        for (String ruleModel : ruleModels()){
            if(Constants.RuleModel.RULE_WEIGHT.equals(ruleModel)) return true;
        }
        return false;
    }
}
